﻿using Simulation.Framework;
using UnityEngine.Events;
using UnityEngine.UI;
using UnityEngine;
using System.Collections.Generic;
using System.Collections;

namespace Easy.Game2d {

    public partial class UIDialoguePanel : PanelBase {

        public TMPro.TextMeshProUGUI ContentTextTextMeshProUGUI{get;private set;}

        public UnityEngine.UI.Button StartButtonButton{get;private set;}

        public UnityEngine.EventSystems.EventTrigger BGEventTrigger{get;private set;}

        public UnityEngine.UI.Image btnBGImageImage{get;private set;}

        public UnityEngine.RectTransform btnBGImageRectTransform{get;private set;}

        public UnityEngine.RectTransform BGRectTransform{get;private set;}

        public UnityEngine.RectTransform ImagebgRectTransform{get;private set;}

        #region control
        private void InitComponent() {
            // init
            ContentTextTextMeshProUGUI = transform.Find("Imagebg/ContentText").GetComponent<TMPro.TextMeshProUGUI>();
            StartButtonButton = transform.Find("StartButton").GetComponent<UnityEngine.UI.Button>();
            BGEventTrigger = transform.Find("BG").GetComponent<UnityEngine.EventSystems.EventTrigger>();
            btnBGImageImage = transform.Find("btnBGImage").GetComponent<UnityEngine.UI.Image>();
            btnBGImageRectTransform = transform.Find("btnBGImage").GetComponent<UnityEngine.RectTransform>();
            BGRectTransform = transform.Find("BG").GetComponent<UnityEngine.RectTransform>();
            ImagebgRectTransform = transform.Find("Imagebg").GetComponent<UnityEngine.RectTransform>();

            // button
            StartButtonButton.onClick.RemoveAllListeners();
            StartButtonButton.onClick.AddListener(OnStartButtonButtonClicked);
        }

        private void ClearComponent() {
            ClearBGClickEvent();
            // button
            StartButtonButton?.onClick.RemoveAllListeners();

            // clear
            ContentTextTextMeshProUGUI = null;
            StartButtonButton = null;
            BGEventTrigger = null;
            btnBGImageImage = null;
            btnBGImageRectTransform = null;
            BGRectTransform = null;
            ImagebgRectTransform = null;
        }
        #endregion
    }
}
